function loadWorkSpaceNum() {
	// alert("加载工作台任务数量");
	request = new Object();
	request.operation = "getTask";
	request.jsonObject = new Object();
	request.jsonObject.na = "na";
	$
			.post("Gate", {
				req : JSON.stringify(request)
			},
					function(data, status) {
						if (status == "success") {
							var resp = eval("(" + data + ')');
							if (resp.status == 0) {
								$("#getTaskbyWeek").text(
										resp.entity.getTaskbyWeek);
								$("#getTaskbyState").text(
										resp.entity.getTaskbyState);
								$("#getTaskbyReader").text(
										resp.entity.getTaskbyReader);
								$("#getVote").text(resp.entity.getVote);
								$("#getTaskbyCompletion").text(
										resp.entity.getTaskbyCompletion);
								$("#newTask").text(resp.entity.newTask);
								$("#getTaskbyDeadline").text(
										resp.entity.getTaskbyDeadline);
								$("#getTaskupDeadline").text(
										resp.entity.getTaskupDeadline);
								// alert(resp.entity);
							} else {
								alert("获取用户任务失败，错误原因：" + resp.message
										+ "，请重新登陆！");
								self.location = "login.html";
							}
						} else {
							alert("HTTP请求异常，请重新登陆！");
							self.location = "login.html";
						}
					});

}
// showLineChart方法，传入（时间：任务数量）JsonObjectList
function showLineChart(userLineChartList) {
	// alert(userLineChartList);
	var ctx, data, myLineChart1, myLineChart2, options;

	var labels = [];
	var data1 = [];
	var data2 = [];
	var data3 = [];
	for (var i = 0; i < userLineChartList.length; i++) {
		data1.push(userLineChartList[i].createSum);// 第一组数据
		data2.push(userLineChartList[i].impSum);// 第二组数据
		data3.push(userLineChartList[i].readerSum);// 第三组数据
		labels.push(userLineChartList[i].date);// 组装x轴上显示得label
	}
	// alert(labels);

	Chart.defaults.global.responsive = true;
	var lineChartOptions = {
		// Boolean - If we show the scale above the chart data
		// 网格线是否在数据线的上面
		scaleOverlay : false,
		// Boolean - If we want to override with a hard coded scale
		// 是否用硬编码重写y轴网格线
		scaleOverride : false,
		// ** Required if scaleOverride is true **
		// Number - The number of steps in a hard coded scale
		// y轴刻度的个数
		scaleSteps : null,
		// Number - The value jump in the hard coded scale
		// y轴每个刻度的宽度
		scaleStepWidth : null,
		// Number - The scale starting value
		// y轴的起始值
		scaleStartValue : null,
		// String - Colour of the scale line
		// x轴y轴的颜色
		scaleLineColor : "rgba(0,0,0,1)",
		// Number - Pixel width of the scale line
		// x轴y轴的线宽
		scaleLineWidth : 1,
		// Boolean - Whether to show labels on the scale
		// 是否显示y轴的标签
		scaleShowLabels : true,
		// Interpolated JS string - can access value
		// 标签显示值
		scaleLabel : "<%=value%>",
		// String - Scale label font declaration for the scale label
		// 标签的字体
		scaleFontFamily : "'Arial'",
		// Number - Scale label font size in pixels
		// 标签字体的大小
		scaleFontSize : 12,
		// String - Scale label font weight style
		// 标签字体的样式
		scaleFontStyle : "normal",
		// String - Scale label font colour
		// 标签字体的颜色
		scaleFontColor : "#666",
		// /Boolean - Whether grid lines are shown across the chart
		// 是否显示网格线
		scaleShowGridLines : true,
		// String - Colour of the grid lines
		// 网格线的颜色
		scaleGridLineColor : "rgba(0,0,0,.1)",
		// Number - Width of the grid lines
		// 网格线的线宽
		scaleGridLineWidth : 1,
		// Boolean - Whether the line is curved between points
		// 是否是曲线
		bezierCurve : true,
		// Boolean - Whether to show a dot for each point
		// 是否显示点
		pointDot : true,
		// Number - Radius of each point dot in pixels
		// 点的半径
		pointDotRadius : 3,
		// Number - Pixel width of point dot stroke
		// 点的线宽
		pointDotStrokeWidth : 1,
		// Boolean - Whether to show a stroke for datasets
		datasetStroke : true,
		// Number - Pixel width of dataset stroke
		// 数据线的线宽
		datasetStrokeWidth : 3,
		// Boolean - Whether to fill the dataset with a colour
		// 数据线是否填充颜色
		datasetFill : true,
		// Boolean - Whether to animate the chart
		// 是否有动画效果
		animation : true,
		// Number - Number of animation steps
		// 动画的步数
		animationSteps : 60,
		// String - Animation easing effect
		// 动画的效果
		animationEasing : "easeOutQuart",
		// Function - Fires when the animation is complete
		// 动画完成后调用
		onAnimationComplete : null,
		// 点击变大
		pointHitDetectionRadius : 20,
		// 添加提示标签
		// multiTooltipTemplate : "<%if (datasetLabel){%><%=datasetLabel%>:
		// <%}%><%=
		// value %>"
		multiTooltipTemplate : "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>"

	};
	var x_labels = labels;
	var default_datasets = [ {
		label : "创建任务数",
		fillColor : "#FF1111",
		strokeColor : "#FF1111",
		pointColor : "#FF1111",
		pointStrokeColor : "#fff",
		pointHighlightFill : "#fff",
		pointHighlightStroke : "#22A7F0",
		data : data1
	}, {
		label : "执行任务数",
		fillColor : "rgba(34, 167, 240,0.2)",
		strokeColor : "#22A7F0",
		pointColor : "#22A7F0",
		pointStrokeColor : "#fff",
		pointHighlightFill : "#fff",
		pointHighlightStroke : "#22A7F0",
		data : data2
	}, {
		label : "分阅任务数",
		fillColor : "#DDDD00",
		strokeColor : "#DDDD00",
		pointColor : "#DDDD00",
		pointStrokeColor : "#fff",
		pointHighlightFill : "#fff",
		pointHighlightStroke : "#22A7F0",
		data : data3
	}, ];

	var lineChartData = {
		labels : x_labels,
		datasets : default_datasets
	};

	var lineChartCanvas = $('#workSpaceLineChart').get(0).getContext('2d');
	var lineChart = new Chart(lineChartCanvas);
	var line_chart_handle = lineChart.Line(lineChartData, lineChartOptions);

	// 给图例中的选框增加事件响应
	// 被选中的则显示其对应折线，未选中的不显示
	$('[name = \'line-legend\']:checkbox').each(
					function(key, value) {
						$(this).attr('checked', true);
					
						// 设置checkbox被取消选择之后，将该曲线消除
						$(this).click(function() {
							var index=$(this).attr("value");
											if ($(this).is(':checked')) {
												//alert("插入" + index);
												// 插入被选中折线上的点
												$.each(lineChartData.datasets[index].data,function(key,value) {
																	line_chart_handle.datasets[index].points
																			.push(new line_chart_handle.PointClass(
																					{
																						value : value,
																						label : lineChartData.labels[key],
																						datasetLabel : lineChartData.datasets[index].label,
																						x : line_chart_handle.scale
																								.calculateX(line_chart_handle.scale.valuesCount + 1),
																						y : line_chart_handle.scale.endPoint,
																						strokeColor : line_chart_handle.datasets[index].pointStrokeColor,
																						fillColor : line_chart_handle.datasets[index].pointColor
																					}));
																});
												line_chart_handle.update();
											} else {
												//alert("删除"+index);
												// 删除被选中折线上的点
												
												for (var i = line_chart_handle.datasets[index].points.length - 1; i >= 0; i--) {
													line_chart_handle.datasets[index].points.shift();
												}
												line_chart_handle.update();
											}
											// 删除被选中折线上的点
										});
					});

}

// Line chart 获取uer的前后7天任务数，并调用chartJs画图
function loadWorkSpaceLineChart() {
	// alert("加载loadLineChart");
	request = new Object();
	request.operation = "getLineChart";
	request.jsonObject = new Object();
	request.jsonObject.id = thisUser.id;
	$.post("Gate", {
		req : JSON.stringify(request)
	}, function(data, status) {
		if (status == "success") {
			var resp = eval("(" + data + ')');
			// alert(resp.entity);
			if (resp.status == 0) {
				showLineChart(resp.entity);
				// alert("查询成功");
			} else {
				alert("获取LineChart失败，错误原因：" + resp.message + "，请重新登陆！");
				self.location = "login.html";
			}
		} else {
			alert("HTTP请求异常，请重新登陆！");
			self.location = "login.html";
		}
	});
}

// PieChart 获取uer的当月任务数，包括（待办未超时、待办超时、已办未超时、已办超时）并调用chartJs画图
function loadWorkSpacePieChart() {
	// alert("加载piechart");
	request = new Object();
	request.operation = "getPieChart";
	request.jsonObject = new Object();
	request.jsonObject.id = thisUser.id;
	$.post("Gate", {
		req : JSON.stringify(request)
	}, function(data, status) {
		if (status == "success") {
			var resp = eval("(" + data + ')');
			showPieChart(resp.entity);
			if (resp.status == 0) {
			} else {
				alert("获取PieChart失败，错误原因：" + resp.message + "，请重新登陆！");
				self.location = "login.html";
			}
		} else {
			alert("HTTP请求异常，请重新登陆！");
			self.location = "login.html";
		}
	});
}

function showPieChart(userPieChartMap) {
	var ctx, data, myPieChart, options;
	Chart.defaults.global.responsive = true;
	ctx = $('#workSpacePieChart').get(0).getContext('2d');
	options = {
		showScale : false,
		scaleShowLabels : true,
		scaleShowGridLines : false,
		scaleGridLineColor : "rgba(0,0,0,.05)",
		scaleGridLineWidth : 0,
		scaleShowHorizontalLines : true,
		scaleShowVerticalLines : false,
		bezierCurve : false,
		bezierCurveTension : 0.4,
		pointDot : false,
		pointDotRadius : 0,
		pointDotStrokeWidth : 2,
		pointHitDetectionRadius : 20,
		datasetStroke : true,
		datasetStrokeWidth : 4,
		datasetFill : true,
		legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].strokeColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
	};
	data = [ {
		value : userPieChartMap.InTimeSuspending,
		// value : 10,
		color : "#1ABC9C",
		highlight : "#1ABC9C",
		label : "未完成"
	}, {
		// value : 5,
		value : userPieChartMap.OutTimeSuspending,
		color : "#FA2A00",
		highlight :"#FA2A00",
		label : "未完成（超时）"
	}, {
		// value : 4,
		value : userPieChartMap.InTimeSolved,
		color : "#FABE28",
		highlight : "#FABE28",
		label : "已完成"
	}, {
		// value : 3,
		value : userPieChartMap.OutTimeSolved,
		color : "#949FB1",
		highlight : "#949FB1",
		label : "已完成（超时）"
	} ];
	mPieChart = new Chart(ctx).Pie(data, options);
}
